package cc.wsyw126.java.test;

import javax.annotation.Resource;
import java.io.*;
import java.net.URL;

/**
 * Created by junpeng.yang on 16/11/4.
 */
public class FindResources {

    public static void main(String[] args) throws IOException {
//        File file = ResourceUtils.getFile("classpath:src/main/resources/FirstSecondTierCity.properties");
//        System.out.println("file = " + file);
//        ResourceUtils.getFile("classpath:FirstSecondTierCity.properties");
//        System.out.println();
//        Resource isr = new ClassPathResource("resources/FirstSecondTierCity.properties");
//        File file = isr.getFile();
//        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
//        String line = null;
//        while ((line = reader.readLine()) != null)// 一行一行读取，每读到一行判断，数据是否为空。
//        {
//                System.out.println(line);
//        }
//
//        Properties properties = PropertiesLoaderUtils.loadAllProperties("FirstSecondTierCity.properties");
//        System.out.print(properties);
//        ObjectMapper mapper = new ObjectMapper();
//        String path = SynPotentialShopInfo.class.getClass().getResource("FirstSecondTierCity.properties").getPath();
//        String hashMap = mapper.readValue(new File(path), String.class);
//
//        System.out.print(hashMap);


        String property = System.getProperty("/test.txt");
        System.out.println("property = " + property);
        URL resource = FindResources.class.getClass().getResource("/test.txt");
        System.out.println("resource = " + resource);
        String file = resource.getFile();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
        String s = null;
        while ((s = bufferedReader.readLine()) != null) {
            System.out.println(s);
        }
        System.out.println(file);


    }
}
